// 处理登陆状态
function isLogin() {
    const ologin = document.querySelector(".login")
    const owelcome = document.querySelector(".welcome")
    const oun = document.querySelector(".un")
    const oexit = document.querySelector(".exit")
    const ogoCart = document.querySelector(".goCart")

    // 读取登录信息
    if (localStorage.getItem("isLogin") === "ok") {
        ologin.style.display = "none";
        owelcome.style.display = "block";
        oun.innerHTML = localStorage.getItem("username");
    } else {
        ologin.style.display = "block";
        owelcome.style.display = "none";
        oun.innerHTML = "xxx";
    }

    oexit.onclick = function () {
        localStorage.removeItem("username");
        localStorage.setItem("isLogin", "");
        ologin.style.display = "block";
        owelcome.style.display = "none";
        oun.innerHTML = "xxx";
    }

    ogoCart.onclick = function () {
        // 购物车拦截
        if (localStorage.getItem("isLogin") === "ok") {
            location.href = "./cart.html"
        } else {
            alert("请先登录再使用购物车")
            location.href = "./login.html"
        }
    }


}